آموزش ++C آموزش و سورس های برنامه نویسی به زبان ++C |
||||||||||||||||||||||||||||||||||||
دو شنبه 11 ارديبهشت 1391برچسب:, :: 22:8 :: نويسنده : کیوان مجنونی
برنامه ای که یک رشته از ورودی گرفته و تعداد حروف بزرگ، حروف کوچک، اعداد، کاراکتر های ویژه و تعداد کلمات را شمرده و نمایش می دهد.
#include #include int main() { int word_counter=0,small_chars=0,large_chars=0,number_counter=0,special_chars=0; char ch=0; cout<<"\n *** This program counts the number of different kinds of characters ***\n " <<"\t\t*** which you use in a paragragh ***\n\n"; cout<<" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \n\n"; cout<<"\n\a>>NOTE: about using space(????)\n" <<"\n\\O/ Now! Enter a paragragh (and press enter 4end):\n\n\n"; cout<<"\t\t\t * * * * * \n\n "; while((ch=getche())!='\r') { if(ch>='a'&&ch<='z') small_chars++; else if(ch>='A'&&ch<='Z') large_chars++; else if(ch>='0'&&ch<='9') number_counter++; else if(ch==' '||ch==',' || ch=='.') word_counter++; else special_chars++; } word_counter++; cout<<"\n\n >Word Count= "< <<"\n\n >Large Characters Count= "< <<"\n\n >Special Characters Count= "< نظرات شما عزیزان:
آخرین مطالب آرشيو وبلاگ پیوندهای روزانه پيوندها
![]() نويسندگان
|
||||||||||||||||||||||||||||||||||||
![]() |